package com.cn.wanxi.util.servlet;

import com.cn.wanxi.util.model.AboutNavModel;
import com.cn.wanxi.util.model.CommunalTitle;
import com.cn.wanxi.util.model.CourseModel;
import com.cn.wanxi.util.service.impl.AboutNavService;
import com.cn.wanxi.util.service.impl.CourseService;
import com.cn.wanxi.util.service.impl.HeaderService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/CourseModelServlet")
public class CourseModelServlet extends HomeServletServlet {
    AboutNavService aboutNavService =new AboutNavService();
    HeaderService headerService =new HeaderService();
    CourseService courseService =new CourseService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doGet(req, resp);
        //页面小导航
        List<AboutNavModel> aboutNavModels =aboutNavService.getaboutNavM();
        req.setAttribute("aboutNavModels",aboutNavModels);

        //内容标题
        List<CommunalTitle> communalTitles = headerService.getCommunalTitle();
        req.setAttribute("communalTitles",communalTitles);

        //课程内容
        List<CourseModel> courseModels = courseService.getcourseModel();
        req.setAttribute("courseModels",courseModels);

        gotoCourseModel(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        gotoCourseModel(req,resp);
    }
    private void gotoCourseModel(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher("/jsp/Course-model.jsp").forward(req,resp);
    }
}
